package edu.zut.Vehicle.phf.message.service;

import edu.zut.Vehicle.phf.message.domain.MyMessage;

import java.util.ArrayList;
import java.util.List;

public class MyReceiver implements Consumer {
    private List<Consumer> consumers;

    public MyReceiver() {
        this.consumers = new ArrayList<>();
    }

    public void addConsumer(Consumer consumer) {
        consumers.add(consumer);
    }

    @Override
    public void consume(MyMessage message) {
        for (Consumer consumer : consumers) {
            consumer.consume(message);
        }
    }
}
